#ifndef __BE_CONTROLLER__
#define __BE_CONTROLLER__

class Controller
{
 protected:
  UINT64 lastUpdate;
  Controller();

 public:
  virtual ~Controller();
  
  void update(const UINT64 &_time);  // Don't override this process
  virtual void internalUpdate(const UINT64 &_time) = 0;
};

class LocationController : public Controller
{
 private:
  Turple3f &loc;
  TrackPtr track;

 public:
  LocationController(Turple3f &_loc);
  ~LocationController();

  void setTrack(TrackPtr _track);
  void internalUpdate(const UINT64 &_time);
};

class OrientationController : public Controller
{
 private:
  Turple3f &ori;

 public:
  OrientationController(Turple3f &_ori);
  ~OrientationController();

  void internalUpdate(const UINT64 &_time);
};

class ControllerGroup : public Controller
{
 private:
  ControllerList controllers;

  class UpdateFunc : public std::unary_function<ControllerPtr , void>
  {
  private:
    const UINT64 &time;
  public:
    UpdateFunc(const UINT64 &_time);
    void operator() (ControllerPtr _controller);
  };

 public:
  ControllerGroup();
  ~ControllerGroup();
  void addController(ControllerPtr _controller); 
  void internalUpdate(const UINT64 &_time);
};

#endif
